/**
 * 
 */
package cn.springsoter.core.tool.utils;

import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;

import org.apache.commons.lang3.concurrent.BasicThreadFactory;

/**
 * 任务调度线程池工具类：用于延迟队列
 * 
 * @author kevin
 *
 */
public class ScheduledExecutorUtil {
	
	private ScheduledExecutorUtil() {
		
	}
	
	/**
	 * 静态内部类实现单例
	 * 
	 * @author kevin
	 *
	 */
	private static class ScheduledExecutorServiceHolder{
		private static ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(8 * 3,
		        new BasicThreadFactory.Builder().namingPattern("springsoter-%d").daemon(true).build());
	}
	
	/**
	 * 获取延时任务调度ScheduledExecutorService对象（单例）
	 * 
	 * @return
	 */
	public static ScheduledExecutorService getScheduledExecutorService() {
		return ScheduledExecutorServiceHolder.executor;
		
	}
}
